using System;
using FU.Capstones.IMS.Web.Common;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.DataContracts;
using FU.Capstones.IMS.Web.Common.InventoryServiceProxy.EventArgs;

namespace FU.Capstones.IMS.Web.Silverlight.Models
{
    public class PartnerDetailModel : ModelBase
    {
        public PartnerDetailModel()
        {
            client.GetSinglePartnerCompleted += DoGetSinglePartnerCompleted;
            client.InsertPartnerCompleted += DoInsertPartnerCompleted;
            client.UpdatePartnerCompleted += DoUpdatePartnerCompleted;
            client.DeleteContactCompleted += DoDeleteContactCompleted;
        }

        #region UpdatePartner

        public event EventHandler<FeedbackCompletedEventArgs> UpdatePartnerCompleted;

        public int UpdatePartnerAsync(Partner data)
        {
            client.UpdatePartnerAsync(data);
            return WebConstants.MagicNumer;
        }

        void DoUpdatePartnerCompleted(object sender, FeedbackCompletedEventArgs e)
        {
            if (UpdatePartnerCompleted != null)
            {
                UpdatePartnerCompleted(sender, e);
            }
        }

        #endregion

        #region InsertPartner

        public event EventHandler<SingleFeedbackCompletedEventArgs<int>> InsertPartnerCompleted;

        public int InsertPartnerAsync(Partner partner)
        {
            client.InsertPartnerAsync(partner);
            return WebConstants.MagicNumer;
        }

        void DoInsertPartnerCompleted(object sender, SingleFeedbackCompletedEventArgs<int> e)
        {
            if (InsertPartnerCompleted != null)
            {
                InsertPartnerCompleted(sender, e);
            }
        }

        #endregion

        #region GetSinglePartner

        public event EventHandler<SingleFeedbackCompletedEventArgs<Partner>> GetSinglePartnerCompleted;
      
        public int GetSinglePartnerAsync(int partnerID)
        {
            client.GetSinglePartnerAsync(partnerID);
            return WebConstants.MagicNumer;
        }

        void DoGetSinglePartnerCompleted(object sender, SingleFeedbackCompletedEventArgs<Partner> e)
        {
            if (GetSinglePartnerCompleted != null)
            {
                GetSinglePartnerCompleted(sender, e);
            }
        }

        #endregion

        #region DeleteContact

        public event EventHandler<FeedbackCompletedEventArgs> DeleteContactCompleted;

        public int DeleteContactAsync(int data)
        {
            client.DeleteContactAsync(data);
            return WebConstants.MagicNumer;
        }

        void DoDeleteContactCompleted(object sender, FeedbackCompletedEventArgs e)
        {
            if (DeleteContactCompleted != null)
            {
                DeleteContactCompleted(sender, e);
            }
        }

        #endregion
    }
}